home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / blu / articles / bluindex.tex (.txt) < prev   
LaTeX Document  |  1994-11-20  |  59KB  |  1,914 lines

  1. %Copyright: C.G. van der Laan, cgl@rc.service.rug.nl, 05941-1525
  2. %Version November 1994
  3. \input blue.fmt  %\tolerance500\hbadness=499\hfuzz=5pt
  4. \title{BLUe's Index}
  5. \subtitle{---The principle, and some more\footnote*
  6.  {BLUe stands for Mr. BLUe---my innocent user and relative of
  7.   Ben Lee User of the \TeX book fame.}}
  8. \issue{MAPS 95.1}
  9. \keywords{Compatible extension, education,
  10. index, macro writing,
  11. number ranges,
  12. one-pass job, ordering table,
  13. plain \TeX,
  14. reusable software parts,
  15. software engineering,
  16. sort keys.
  17. \abstract{The creation of a modest index within
  18. a one-pass \TeX{} job is proposed. In general a proof run
  19. and a final run are needed.}
  20. \contents{Introduction
  21. \quad The process and files involved
  22. \quad Why?
  23. \quad Disclaimer
  24. \quad Notations and definitions
  25. Example of use: From the \TeX book
  26. Example of use: Accents and the like
  27. Index Reminders
  28. \quad Syntax
  29. \quad Markup
  30. \quad Examples of IR markup
  31. \qquad Spaces
  32. \quad Writing IRs
  33. Sort and compress: \cs{sortindex}
  34. \quad Storing in an array
  35. \quad Sorting
  36. \qquad Ordering
  37. \qquad Ordering table
  38. \qquad To be ignored tokens
  39. \quad Reduction of entries
  40. \quad Transformation index.srt$\rightarrow$index.elm
  41. Typeset: \cs{pasteupindex}
  42. \quad Running headlines
  43. Customization
  44. \quad Adding tokens to be ignored
  45. \quad Modifying ordering
  46. \quad Enriching the index
  47. \quad Typesetting the enriched file
  48. Tests
  49. Robustness
  50. Availability, and what is needed from manmac
  51. Looking backward
  52. Looking forward
  53. \quad Subsidiary entries
  54. \quad Sorting keys
  55. Acknowledgements, Conclusion, References
  56. Appendix A: Data: IRs from \TeX book chapter 1-6
  57. Appendix B: Index
  58. Appendix C: The index macros.
  59. \thisreferences{\TB{} and \LaTeX{} user's guide
  60. are omni-present and not explicitly listed.}
  61. \references{\chenp\dolwc
  62.  \laancgh\laancgm\laancgv\makeindex\salomonda\salomondg}
  63. %\loadallpictures
  64. %\pictures{\indmodelpic}
  65. \catcode`\^=7
  66. {\catcode`\^=7 \obeylines
  67.  \gdef\verbatimgobble#1^^M{}}
  68. \beginscript
  69. \head{Introduction}
  70. Making an index is an art.
  71. The fundamental problem is
  72. \beginquote  What to include in the index?
  73. \endquote
  74. \noindent Computer-assisted indexing is not simple either.
  75. Issues are
  76. \bitem the markup of keywords or phrases
  77. \bitem to associate page numbers
  78. \bitem to sort and compress raw Index Reminders (IRs), and
  79. \bitem to typeset the result.
  80. \smallbreak\noindent
  81. The latter opens the Pandorra box of markup and layout,
  82. which prompts for a two-pass job.
  83. Up till now  the sorting is
  84. done outside of \TeX.\ftn{The index for the
  85.    \TeX book was done by a multi-pass job. In proofmode the raw IRs
  86.    are written to the file index, and in the final run the enriched file
  87.    of index entries is encluded in the script, preceded by special
  88.    markup definitions.}
  89. However, producing a modest index in a one-pass
  90. \TeX{} job is possible.
  91. In `Sorting in BLUe,'
  92. I already touched upon the issue of sorting IRs.
  93. \noindent I'll build upon manmac's
  94. \bitem syntax and types of Index Reminders (IRs)
  95. \bitem writing to a file
  96. \bitem associating page numbers, and
  97. \bitem the formatting in two-columns.
  98. \subhead{The process and files involved.}
  99. Manmac stores the raw IRs in the file index.
  100. I read the file index\ftn{Default index is the value of
  101.   the toks variable \cs{irfile}, which is used in \cs{sortindex}.}
  102. into an array for internal sorting.
  103. After sorting I reduce the entries\ftn{Those which differ by page
  104.    number are collected into one entry.}
  105. and write the result to the file index.srt.
  106. Then, I transform index.srt into the file
  107. index.elm.\ftn{ Default index.elm is the value of the toks variable
  108.       \cs{indexfile}, which is used in \cs{pasteupindex}.
  109.       The transformation abandons the IR syntax.
  110.       The part which specifies the kind of IR
  111.       is deleted and the word part marked up
  112.       accordingly.}
  113. The result is typeset via \cs{pasteupindex}.
  114. \subhead{Schematically} it comes down to
  115. \bigskip
  116. $$\vcenter{%\indmodelpic
  117. \unitlength=6ex
  118.  \xdim{7.5}\ydim{4}
  119. \beginpicture
  120. \put(2,0){\makebox(0,0){Result}}
  121. \put(2,1){\vector(0,-1){.8}}
  122. \put(2,1.25){\makebox(0,0){\cs{pasteupindex}}}
  123. \put(5.5,1.6){\vector(-1,0){3}}
  124. \put(2,3){\vector(0,-1){1.5}}
  125. \put(2,3.25){\makebox(0,0){\cs{sortindex}}}
  126. \put(2.5,2.9){\line(1,0){3}}
  127. \put(5.5, 2.9){\vector(0,-1){.5}}
  128. \put(5.5, 2.25){\makebox(0,0){`Enrich' index.elm\ }}
  129. \put(5.5, 2){\line(0,-1){.4}}
  130. \put(2,4.3){\vector(0,-1){.8}}
  131. \put(2,4.5){\makebox(0,0){Copy + IR markup}}
  132. \endpicture
  133. \subhead{Why?}
  134. For a professional index I agree with Knuth that one
  135. can better sort and otherwise enrich the index outside
  136. of \TeX. This obeys the separation of concerns principle.
  137. However, there is nothing against it to provide
  138. macros for producing modest indexes completely within \TeX.
  139. Objections\ftn{If any :-).} will faint away hopefully,
  140. because of the possibility
  141. to {\it enrich the sorted and compressed
  142. index (file) outside of \TeX.}
  143. The latter is a step beyond manmac.
  144. There the raw IRs are written to the file index,
  145. while here the sorted and compressed IRs
  146. can be worked upon.
  147. My work is a compatible extension of manmac,
  148. meaning that one can also start from the raw IRs,
  149. if one wishes.
  150. A side-effect is that the power of \TeX{} for practical
  151. problems is demonstrated.
  152. \subhead{Disclaimer.}
  153. The macros are not foolproof.
  154. Don't use as part of the IR
  155. \bitem \TeX's special symbols
  156. \bitem symbols with special catcodes, for example active symbols like
  157.        the circumflex \char94,
  158.        or the tilde \char126
  159. \bitem as part of the IR a control sequence which is not accounted for.\ftn{In
  160. the section
  161.           Looking forward I'll explain how a user can allow for
  162.           control sequences as part of the IR markup.}
  163. \smallbreak
  164. \subhead{Notations and definitions.}
  165. manmac.tex stands for the macros used by Knuth for formatting
  166. his Computers and Typesetting series of books, especially the \TeX book
  167. and the \MF{} book.
  168. Index reminders denote the markup of script words, to be included
  169. in the index.
  170. IRs is an abbreviation for Index Reminders.
  171. \cs{ea}, \cs{nx} denote \cs{expandafter} and \cs{noexpand}.
  172. OTR stands for output routine.
  173. FIFO stands for First In First Out, as described in `FIFO and LIFO sing the
  174. BLUes.' SiB denotes my `Sorting in BLUe' work.
  175. \head{Example of use: From the \TeX book}
  176. Let us take for this example some IRs from the first chapter
  177. of the \TeX book. I took only part of it and introduced
  178. \cs{newpage} now and then to enforce pages with zero, one or more
  179. IRs. I used blue.fmt (with manmac embedded).
  180. \thisverbatim{\catcode`\|=12 }
  181. \beginverbatim
  182. %Text from first chapter TeX book
  183. Hence the name \TeX, which is an
  184. uppercase form of $\tau\epsilon\chi$.
  185. ^^{TeX, meaning of}%modified
  186. ^^|\tau|^^|\epsilon|^^|\chi|
  187. \newpage%no IRs next
  188. Insiders pronounce the $\chi$ of \TeX\ as
  189. a  Greek chi, not as an `x', so that
  190. \TeX\ rhymes with the word blecchhh.
  191. \newpage%three IRs next
  192. In fact, ^{TEX} (pronounced {\sl tecks\/})
  193. is the admirable {\sl Text EXecutive\/}
  194. processor developed by^{Honeywell HIS}.
  195. Since these two system names are
  196. ^^{Bemer, Robert}
  197. pronounced quite differently, they should
  198. also be spelled differently.
  199. \newpage%one IR next
  200. The correct way to refer to \TeX\ in a
  201. computer file, or when using some other medium
  202. that doesn't allow lowering of the `E',
  203. is to type `^|TeX|'. Then there will be no
  204. confusion with similar names, and people will
  205. be primed to pronounce everything properly.
  206. \sortindex
  207. \pasteupindex
  208. !endverbatim
  209. \noindent which yields as  raw IRs (in file index)
  210. \thisverbatim{\catcode`\*=0
  211.    \catcode`\!=12 }
  212. \beginverbatim
  213. TeX, meaning of !0 1.
  214. tau !2 1.
  215. epsilon !2 1.
  216. chi !2 1.
  217. TEX !0 3.
  218. Honeywell HIS !0 3.
  219. Bemer, Robert !0 3.
  220. TeX !1 4.
  221. *endverbatim
  222. \noindent and as index (in file index.elm)
  223. \bigbreak\noindent{\bf Index}
  224. \medskip\noindent
  225. \line{\vbox{\noindent\hsize.5\hsize
  226. \noindent {Bemer, Robert}{} 3.
  227. \noindent {\tt \char 92\hbox {chi}}{} 1.
  228. \noindent {\tt \char 92\hbox {epsilon}}{} 1.
  229. \noindent {Honeywell HIS}{} 3.
  230. }\vbox{\noindent\hsize.5\hsize
  231. \noindent {\tt \char 92\hbox {tau}}{} 1.
  232. \noindent {TEX}{} 3.
  233. \noindent {\tt TeX}{} 4.
  234. \noindent {TeX, meaning of}{} 1.
  235. }\hss}
  236. \head{Example of use: Accents and the like}
  237. I'll show how to mark up Knuth's four types of IRs
  238. and how to mark up accents, font switching, and
  239. spaces as part of the IR.
  240. The last IR markup shows that the  representation of page numbers
  241. as a range comes out automatically too.
  242. \thisverbatim{\catcode`\|=12
  243.    \catcode`!=12 \catcode`\*=0 }
  244. \beginverbatim
  245. Types of IR
  246.  0  ^{return}
  247.  1  ^|verbatim|
  248.  2  ^|\controlsequence|
  249.  3  ^\<syntactic quantity>
  250. Accents in IR markup  ^{\'el\`eve!},
  251. font changing in IR markup ^{\bf bold}
  252. and spaces in IR markup ^{control\ symbol}
  253. Control sequences ^{\TeX, and \AmSTeX}
  254. ^{Lamport and \LaTeX}
  255. brackets ^{\tt< \rm and \tt>}
  256. \newpage range representation ^{return}
  257. \newpage                      ^{return}
  258. \sortindex
  259. \pasteupindex
  260. *endverbatim
  261. \noindent The above yields in file index as raw IRs
  262. \thisverbatim{\catcode`\*=0
  263.    \catcode`\!=12 }
  264. \beginverbatim
  265. return !0 1.
  266. verbatim !1 1.
  267. controlsequence !2 1.
  268. syntactic quantity !3 1.
  269. \'el\`eve! !0 1.
  270. \bf{}bold !0 1.
  271. control\ symbol !0 1.
  272. \TeX, and \AmSTeX{} !0 1.
  273. Lamport and \LaTeX{} !0 1.
  274. \tt{}< \rm{}and \tt{}> !0 1.
  275. return !0 2.
  276. return !0 3.
  277. *endverbatim
  278. \noindent and in file index.elm as index
  279. \bigbreak\noindent{\bf Index}
  280. \medskip\noindent
  281. \line{\vbox{\noindent\hsize.5\hsize
  282. \noindent {\tt {}< \rm {}and \tt {}>}{} 1.
  283. \noindent {\bf {}bold}{} 1.
  284. \noindent {control\ symbol}{} 1.
  285. \noindent {\tt \char 92\hbox {controlsequence}}{} 1.
  286. \noindent {\'el\`eve!}{} 1.
  287. }\vbox{\noindent\hsize.5\hsize
  288. \noindent  {Lamport and \LaTeX{}} 1.
  289. \noindent {\TeX, and \AmSTeX{}} 1.
  290. \noindent {return}{} 1--3.
  291. \noindent $\langle \hbox {syntactic
  292.              quantity}\rangle ${} 1.
  293. \noindent {\tt verbatim}{} 1.
  294. }\hss}
  295. \head{Index Reminders}
  296. IRs are at the heart of the process. Knuth distinguished 4 types
  297. to facilitate the outside processing.
  298. I'll adopt his IRs syntax and types.
  299. \subhead{Syntax.}
  300. Knuth's IRs obey the syntax\ftn{In
  301.   contrast with my previous given syntax it seems that Knuth was less
  302.   restrictive. Earlier I overlooked that the entries are ended by
  303.   a period.}
  304. \thisverbatim{\emc}
  305. \beginverbatim
  306. <word(s)>!]!!<digit>!]<page number>.
  307. !endverbatim
  308. The digits  0, 1, 2, or 3 denote the types: words,
  309. verbatim words, control sequence, and syntactic quantity.
  310. A user does not have to bother about the digits, nor about the
  311. page numbers.
  312. Knuth has adopted the accompanying conventions for
  313. the word(s) of IRs.\ftn{See \TB, p424 for the IR types, and what is typeset
  314.    in the result. In \cs{vref} the markup is inserted as replacement
  315.    text of \cs{next}. What is set in the index is governed by the macros which
  316.     are included after \cs{begindoublecolumns} in the \TeX book script.}
  317. $$\vbox{\offinterlineskip\def\tstrut{\vrule height2.5ex depth.5ex width0pt}
  318. \halign{\tstrut#\hfill\quad\vrule\quad&#\hfill\quad\vrule\quad&#\hfill\cr
  319. Mark up&Typeset in copy$^*$&IR \cr
  320. \noalign{\hrule}
  321. |^{...}|  &\dots        &|... !!0 |$\langle page\, no\rangle$.\cr
  322. |^!vrt...!vrt|  &|!vrt...!vrt|&
  323.                               |... !!1 |$\langle page\, no\rangle$.\cr
  324. |^!vrt\...!vrt| &|!vrt\...!vrt| &
  325.                                |... !!2 |$\langle page\, no\rangle$.\cr
  326. |^\<...>|&$\langle\dots\rangle^{**}$&
  327.                                |... !!3 |$\langle page\, no\rangle$.\cr
  328. \noalign{\vskip.5ex\hrule width1cm\relax\vskip1ex}
  329. \multispan3{\quad$^*\,$\vrt\dots\vrt\ denotes manmac's, TUGboat's,\dots
  330.    verbatim.  \hfil}\cr
  331. \multispan3{\quad$^{**}\,$in \cs{rm}. \hfil}\cr
  332. For the user the word(s) are important.
  333. The allowed markup for the IRs and the result in the copy are
  334. given in the accompanying table.
  335. \subhead{Markup.} The markup for IRs is near to natural.
  336. Precede the entry by a circumflex  (or  two circumflex(es) in case of
  337. a silent index entry).\ftn{Silent IRs mean that these  will appear
  338.    only in the index, not on the page.}
  339. \example{IR markup.}
  340. \thisverbatim{\catcode`\|=12 \catcode`\^=12
  341.    \catcode`!=12 \catcode`*=0 }
  342. \beginverbatim
  343. ^{text, e.g. \'el\`eve!}
  344. ^|verbatim text|
  345. ^|\controlsequence|
  346. ^\<a metalinguistic variable>
  347. %and for silent ones, double the ^
  348. ^^\<a metalinguistic variable>
  349. %from the TeX book
  350. {\sl^{ligatures}}
  351. |'$|^|\,||$''|
  352. ^^{markup commands, see control sequences}
  353. %from Looking forward section
  354. ^{Lamport and \LaTeX}
  355. *endverbatim
  356. \subsubhead{Spaces} are as always difficult.
  357. In the IR they separate parts of the IR, and are used
  358. in the word part.
  359. Just typing a space has as effect that
  360. it will be neglected during  sorting.
  361. The markup `\cs{\char32}', a control space,
  362. will yield a space subject to sorting, according to
  363. the ordering table.
  364. \cs{space} markup will be neglected during sorting.
  365. This token is default member of
  366. the set of to be ignored control sequences.
  367. It will be set in the index as \cs{\char32}.
  368. \example{Spaces}
  369. The following markup
  370. \thisverbatim{\catcode`\|=12 }
  371. \beginverbatim
  372. Spaces test
  373. ^{\space}%an ignored cs
  374. ^{a\ a}  %control space
  375. ^{aa}
  376. ^{a\ b}
  377. ^{a \TeX}
  378. ^{a\ \bf a}
  379. ^{\TeX book}
  380. ^{xyz beta}%negelected in sorting
  381. ^{xyza}
  382. ^|\space|
  383. \sortindex
  384. \pasteupindex
  385. !endverbatim
  386. \noindent yields as file index
  387. \thisverbatim{\catcode`\!=12
  388.               \catcode`\;=0 }
  389. \beginverbatim
  390. \space {} !0 1.
  391. a\ a{} !0 1.
  392. aa{} !0 1.
  393. a\ b{} !0 1.
  394. a \TeX {} !0 1.
  395. a\ \bf a{} !0 1.
  396. \TeX book{} !0 1.
  397. xyz beta{} !0 1.
  398. xyza{} !0 1.
  399. space{} !2 1.
  400. ;endverbatim
  401. \noindent and as file index.srt
  402. \thisverbatim{\catcode`\!=12
  403.               \catcode`\;=0 }
  404. \beginverbatim
  405. \space {} !0 1.
  406. a\ \bf a{} !0 1.
  407. a\ a{} !0 1.
  408. a\ b{} !0 1.
  409. aa{} !0 1.
  410. a \TeX {} !0 1.
  411. space{} !2 1.
  412. \TeX book{} !0 1.
  413. xyza{} !0 1.
  414. xyz beta{} !0 1.
  415. ;endverbatim
  416. Explanation. \cs{space} belongs to the set of to be
  417. ignored control sequences, ICSs for short.
  418. This means that it is skipped with respect to sorting,
  419. except when it occurs as the last token of the word part.
  420. In that case they are ordered as a space,
  421. that is according to the lowest value.
  422. This explains the position of `\cs{space}.'
  423. `\cs{TeX},' and `\cs{TeX} book,' are subject to the default sort keys.
  424. `xyza' precedes `xyz beta,' because the space is silent.
  425. When word ordering is preferred a \cs{\char32}, a control space,  must
  426. be included.
  427. \subhead{Writing the IRs in index.}
  428. This comes with manmac.
  429. The writing is done in two phases:
  430. first while processing the script, and
  431. second in the OTR where the page numbers are attached.
  432. The (manmac) macro which does the first part of the
  433. writing is
  434. \thisverbatim{\catcode`\~=0
  435.    \catcode`\!=12 }
  436. \beginverbatim
  437. \def\makexref{\ifproofmode
  438.    \bgroup\def\ {\string\ }%
  439.    \xdef\writeit{\write\inx{\text{}
  440.     !\xreftype\space
  441.     \nx\number\pageno.}}\writeit
  442.    \egroup
  443.    \else\ifhmode\kern0pt\fi\fi
  444.    \ifsilent\ignorespaces\else\next\fi}
  445. ~endverbatim
  446. I don't write in the margin.
  447. In Appendix C the  full-BLUe
  448. macro has been provided.
  449. Font changing control sequences, accents and \cs{space}
  450. are written as a `string' in the file index.
  451. Actually, I introduced also the sorting on sorting keys.
  452. Because of the different use of \cs{space}
  453. I introduced \cs{spaceseparator}.
  454. \head{Sort and compress: \cs{sortindex}}
  455. The functionality of \cs{sortindex} is to transform the file of
  456. raw index reminders---index---into the file with sorted and compressed
  457. index entries---index.elm.
  458. All we have to do is to
  459. \bitem write the raw IRs in the array,
  460.        and keep the upper bound of the array in \cs{n},
  461. \bitem sort with the right comparison macro (\cs{cmpir}, and
  462.         at the lower level for the word part \cs{nxtwindex}),
  463.         next to the use of the ordering table \cs{otindex}
  464. \bitem reduce the index entries by collecting the same entries which differ
  465.        by page number
  466. \bitem write the result to the file index.srt, and transform this into
  467.        index.elm.
  468. \smallbreak
  469. \beginverbatim
  470. \def\sortindex{%Nov 1994, cgl
  471. %Purpose:
  472. %To sort IR file.
  473. %Input: default index is sorted
  474. %      ( file specified in \irfile)
  475. %Output: file index.elm.
  476. \newpage\immediate\closeout\inx
  477. \filetoarray{\the\irfile}
  478. \immediate\write16{Sorting n=\the\n.
  479.     Please wait, O(nlog n) process.}
  480. \let\cmp\cmpir\let\nxtw\nxtwindex
  481. \otindex\let\ \space
  482. \sort
  483. {\let\spaceseparator\space
  484.  \setupnxtokens\def\ {\nx\ }%
  485.  \immediate\write16{Range reduction.}
  486.  \redrngtofile{index.srt}
  487.  \immediate\write16{After reduction and
  488.   writing to file index.srt; n=\the\n.}
  489.  \immediate\write16{Transform
  490.        index.srt-->index.elm.}
  491.  \tawfiletofile{index.srt}{\the
  492.                   \indexfile}}}
  493. !endverbatim\noindent
  494. with auxiliary
  495. \beginverbatim
  496. \def\setupnxtokens{%
  497.  \def\process##1{\def##1{\nx##1}}%
  498.   \ea\fifo\the\conseqs\ofif
  499.  \def\process##1{\def##1{\string##1}}%
  500.   \ea\fifo\the\consyms\ofif
  501. !endverbatim\noindent
  502. In Appendix C the full-BLUe version has been incorporated.
  503. \subhead{Storing in an array.}
  504. The storing of data from a file into an array has been
  505. treated in SiB. A slightly modified version of the
  506. macro reads
  507. \beginverbatim
  508. \def\filetoarray#1{%#1 is file name
  509.  \immediate\openin\inxin=#1\relax
  510.  \ifeof\inxin\immediate\write16{File #1 empty
  511.    or non-existent.}%
  512.  \fi \n\kzero\continuetrue
  513.  \loop\ifeof\inxin\continuefalse\fi
  514.  \ifcontinue\advance\n1 \immediate
  515.  \read\inxin t\ea o\csname\the\n\endcsname
  516.  \repeat\advance\n-1
  517.  \immediate\closein\inxin}
  518. !endverbatim
  519. \subhead{Sorting.}
  520. For sorting I make use of my macros as released in SiB.
  521. Comparison needs a multiple key.
  522. This means that at the outer level we have to
  523. supply \cs{cmpir}\ftn{Mnemonics compare index reminder.} and at the lower level
  524. have to compare words, and digits.
  525. The words are handled by \cs{nxtwindex} and the numbers
  526. are compared via an \cs{ifnum}. The comparison macro for
  527. IRs reads
  528. \thisverbatim{\unmc}
  529. \beginverbatim
  530. \def\cmpir#1#2{%#1, #2 defs
  531. %Result: \status= 0, 1, 2 if
  532. %        \val{#1} =, >, < \val{#2}
  533. \ea\ea\ea\decom\ea#1#2}
  534. !endverbatim
  535. The crucial macro for comparison of the word part of the IR reads
  536. \beginverbatim
  537. \def\nxtwindex#1#2{%
  538. %Function:
  539. %On input: #1 contains the `word'
  540. %As result: #2 contains the value
  541. %   of the first non-ignored token as given
  542. %   in the ordering table.
  543. %#1 contains the rest of the `word'
  544.  \def\pop##1##2\pop{%
  545.  \gdef#1{##2}\def\pophead{##1}}%head and tail
  546.  \ea\pop#1\pop%split in head and tail
  547.  \ignores\ea\ea\ea{\ea\the\ea\conseqs
  548.                         \the\consyms}%
  549.  \ea\loc\pophead{\the\ignores}%
  550.  \iffound\ifx\empty#1 \chardef#2=0
  551.          \else\nxtwindex#1#2\fi
  552.  \else
  553.  \ea\let\ea#2\csname ot\pophead\endcsname\fi
  554. %with toks variables
  555. \conseq{\c\space\bf\it\rm\tt\TeX\sub}
  556. \consyms{\`\'\"\^\~}
  557. !endverbatim
  558. The idea is to process the `word' argument by argument.\ftn{Not token
  559.    by token, beware!}
  560. However, some tokens are not relevant for the ordering
  561. and have to be ignored. This is done by collecting
  562. all tokens to be ignored in the toks variable \cs{ignores},
  563. and compare \cs{pophead} with this string.
  564. The above can be extended to control sequences to be sorted on
  565. separately provided sorting keys. See the Looking forward section.
  566. For \cs{decom} and other low level macros related to
  567. sorting within \TeX{} see `BLUe's Format,' or
  568. `Sorting in BLUe.'
  569. In Appendix C the full-BLUe versions have been incorporated.
  570. \subsubhead{Ordering.}
  571. A fundamental issue with indexes is the ordering.
  572. The ASCII table is not suited because lowercase and uppercase
  573. letters differ by 32. I decided to rank these as equal, more
  574. precisely to assign the lowercase ASCII values to both. I prefer
  575. from the following the left column above the right one
  576. \beginverbatim
  577. el                          el
  578. El!`eve                       em
  579. em                          El!`eve
  580. !endverbatim
  581. Moreover, accented letters are not part of ASCII. How should we
  582. order for example e, \'e, \`e, \^e, \"e?
  583. I decided to rank accented letters equal to those without an accent,
  584. because I prefer from the following the left column above the right one
  585. \beginverbatim
  586. el                          el
  587. !leavevmode!'el!`eve                       em
  588. em                          !'el!`eve
  589. !endverbatim
  590. I know that non-letters precede letters but what about there relative
  591. ordering? I decided to stay as close as possible to the ASCII ordering.
  592. Then there is the problem of digits. In IRs they come as part of the
  593. word(s) and as page numbers. For the latter I used the numerical ordering.
  594. For the former I used the alphabetical ordering.\ftn{I could have applied
  595.   a look ahead mechanism and use numerical ordering throughout.
  596.   Maybe another time.}
  597. Furthermore, a user can select
  598. the so-called `word ordering,'\ftn{This means that spaces precedes
  599.     all letters. A space as such is neglected in the ordering.}
  600. by \cs{\char32}, \TeX nically a control space, as markup for a space.
  601. Personally, I like from the following the first column  better than
  602. the second
  603. \beginverbatim
  604. sea lion                    seal
  605. seal                        sea lion
  606. !endverbatim
  607. \subsubhead{Ordering table.}
  608. This ordering `table' is simpler than the one released
  609. in SiB, because accents have been ignored.
  610. Furthermore, I adhere mostly to the ASCII ordering,
  611. as can be seen easily.
  612. \thisverbatim{\catcode`\|=12 \catcode`\!=12
  613.    \catcode`\~=0 }
  614. \beginverbatim
  615. \def\otindex{%Parameters: Ordering `table'
  616. %Special cases
  617. \ea\chardef\csname ot \endcsname=0
  618. \ea\chardef\csname ot\space\endcsname=0
  619. %{|}~char126 come in ASCII after lowercase
  620. %^ is active character
  621. %Bulk according to ASCII
  622. \def\process##1{\ea\chardef
  623.    \csname ot##1\endcsname=`##1 }
  624. %lowercase letters
  625. \fifo abcdefghijklmnopqrstuvwxyz\ofif
  626. \chardef\otij=`y \chardef\otIJ=`y
  627. %other characters}
  628. \fifo!"##$&'()*+,-./0123456789:;<=>?@
  629.       []_`\ofif
  630. %assign lowercase values to uppercase letters
  631. \def\process##1{\ea\chardef
  632.   \csname ot##1\endcsname=\lccode`##1 }
  633. \uppercase{\fifo
  634.   abcdefghijklmnopqrstuvwxyz\ofif}
  635. ~endverbatim
  636. Attention needs \TeX's specials, in particular
  637. the escape character \cs{},
  638. the circumflex \char94,
  639. and the percent \%.
  640. \subsubhead{To be ignored tokens.}
  641. In practice I needed things like \cs{tt}
  642. as part of the IR, which must be neglected while sorting.\ftn{The reason is
  643.   that {\tt <, and >} are used and then printed wrongly.}
  644. I decided to ignore those tokens while sorting and to include
  645. the tokens in the final index.elm as such.
  646. Another realistic approach is to add this kind of markup later in the file
  647. index.elm.
  648. \subhead{Reduction of entries.}
  649. The functionality is that the IRs which differ by page number
  650. are collected into one entry with the page numbers represented
  651. efficiently, for example in ranges.
  652. The macros from SiB have the functionality
  653. \beginverbatim
  654. \def\redrngtofile#1{%Reduction of \1...\n,
  655. %with range representation of page numbers.
  656. %The result is written to file #1.
  657. \def\prcrng#1{%Prints the numbers so far if
  658. %the new number differs more than 1 from the
  659. %last. If the difference is 1 the range is
  660. %extended.
  661. \def\strnrs{%Accumulates numbers in \nrsrng.
  662. %either as a range or as such.
  663. %\frst stands for first number
  664. %and \lst for last number. If they equal the
  665. %number is stored, if they differ by 1 both
  666. %the numbers are stored separated by \sepn,
  667. %and if they differ by more than 1
  668. %\frst--\lst is stored.
  669. !endverbatim
  670. For the first macro see Appendix C. The other two have been released
  671. already as part of blue.fmt and are unaltered.
  672. \subhead{Transformation index.srt$\rightarrow$index.elm.}
  673. When we inspect the copy for the index in the \TeX book file
  674. then we'll find that the entries of the enriched file don't obey
  675. the syntax of the IRs.
  676. The part with !$\langle digit\rangle$ has disappeared.
  677. Pondering about this made me agree with Knuth, as usual.\ftn{I noticed
  678.    furthermore, that some IRs did not make it into the final index.
  679.    Apparently, given the other IRs, he decided to delete less relevant
  680.    ones.}
  681. It is no longer functional!
  682. The file can better be considered as copy as such, to be processed in the
  683. final run.
  684. Because of this I transformed index.srt, the file of sorted and compressed
  685. IRs, into the file index.elm,
  686. with the coding !$\langle digit\rangle$ absorbed as markup in the word part.
  687. \beginverbatim
  688. \def\tawfiletofile#1#2{% #1 from file
  689.  \continuetrue         % #2 to file
  690.  \immediate\openin\inxin=#1\relax
  691.  \immediate\openout\inx=#2\relax
  692.  \loop\read\inxin to\IR
  693.    \ifeof\inxin\continuefalse\fi
  694.  \ifcontinue\trfandwrite\IR
  695.  \repeat
  696.  \immediate\closein\inxin
  697.  \immediate\closeout\inx
  698. %with auxiliaries
  699. \newread\inxin\newwrite\inx\newtoks\indword
  700. \def\splitintoks#1 !#2 #3.{\indword{#1}%
  701.   \chardef\digit=#2\relax\def\pagenrs{#3}}
  702. \def\trfandwrite#1{\ea\splitintoks#1%
  703.  \immediate\write\inx{\nx\noindent
  704.   \ifcase\digit{\the\indword}\or
  705.    {\nx\tt\the\indword}\or
  706.    {\nx\tt\char92\hbox{\the\indword}}\or
  707.    $\nx\langle\hbox{\the\indword}\nx\rangle
  708.     $\fi\spaceseparator\pagenrs.}}
  709. !endverbatim
  710. \subsubhead{Explanation.} In \cs{trfandwrite} I used the
  711. toks variable for storing the word part, because when writing
  712. it comes out handy that \cs{the} is a one-step expansion.
  713. Note that \cs{trfandwrite} takes care of the markup
  714. for \cs{pasteupindex}. The \cs{noindent} is inserted to
  715. enforce horizontal mode, especially in presence of
  716. accents at the beginning of the word.
  717. In \cs{tawfiletofile} the test for the end of file looks
  718. peculiar.\ftn{Remember
  719.    that \TeX{} appends a \cs{par} to the input file.}
  720. \head{Typeset: \cs{pasteupindex}}
  721. In the \TeX book the typesetting of the enriched index entries is
  722. treated on p261--264. Let us start from there and distill
  723. our specifications.
  724. The typesetting of main and subsidiary entries is discussed
  725. given the file of index entries. This is intertwinned with
  726. the page break mechanism
  727. in relation to what should appear in the running headlines.
  728. My specifications for typesetting the index are
  729. \bitem represent the four IR types the same as in the \TeX book
  730. \bitem set in two-columns, balanced, possibly preceded
  731.        by one-column copy
  732. \bitem set subsidiary entries analogous to the \TeX book
  733. \bitem indent continuation lines by 2em
  734. \bitem indent subsidiary entries by 1em
  735. \bitem underline page numbers which represent the definition or
  736.        the main source of information
  737. \bitem represent a page number in italics when that page contains
  738.        an instructive example of the concept in question.
  739. \smallbreak\noindent
  740. Essentially nothing new.
  741. The challenge is how to implement this,
  742. such that an index can be handled in a one-pass job.
  743. In order not to make things too complex, I'll postpone the handling
  744. of subsidiary entries until the Looking forward section.
  745. Let us say that this is a feature for the `next release,' of blue.fmt.
  746. The enrichements such as representation of
  747. numbers in italics or underlined, which have all
  748. to do with the wish to direct readers to the main source or
  749. to instructive examples, are left to the manual editing of
  750. the index.elm file.
  751. The reason is---In agreement with Knuth?---that
  752. this is difficult to foresee at the time when the IR markup is inserted
  753. in the script.
  754. Moreover, it complicates the sorting et cetera process.
  755. In the mean time users can  edit
  756. index.elm---read add markup---and provide the necessary macros
  757. in for example \cs{preindex}. In short follow  Knuth.
  758. The compressed and sorted aray of index entries is
  759. set via the invocation \cs{pasteupindex}.\ftn{As
  760.    modification for the pair \cs{begindoublecolumns}
  761.    and \cs{enddoublecolumns},
  762.    because the latter is too much intertwinned with manmac.
  763.    For an explanation of the underlying macro the reader is referred
  764.    to the \TeX book p416--417.}
  765. The contents of \cs{preindex}
  766. and \cs{postindex} are used appropriately.
  767. \beginverbatim
  768. \def\pasteupindex{%Nov 1994, cgl
  769. %Purpose:
  770. %To set index in (balanced) doublecolumn.
  771. %The index is preceded by contents of
  772. %\preindex and followed by contents of
  773. %\postindex.
  774. %Input: default index.elm is set
  775. %       (file specified in \indexfile).
  776. %Biased by manmac's \begindoublecolumns
  777.  \newpage\begingroup
  778.  \def\space{{\tt\char32 }}%
  779.  \the\preindex\par
  780.  \pageheight\vsize
  781.  \pagewidth\pagewd%anachronism
  782.  \parindent1em
  783.  \output={\global\setbox\partialpage=
  784.   \vbox{\unvbox255\bigskip}}%
  785.  \eject
  786.  \output={\bluedoublecolumnout}%
  787.  \hsize=8.5cm \vsize=51cm%blue.fmt values
  788.  \parskip0pt plus.8pt\relax
  789.  \obeylines\everypar{%
  790.     \hangindent2\parindent}%
  791.  \let\par\endgraf
  792.  \let\sub\endgraf
  793.  \input\the\indexfile\relax
  794. %endpasteupindex part biased by
  795. %manmac's \enddoublecolumns
  796.  \output={\balancecolumns}\eject
  797.  \endgroup
  798.  \pagegoal=\vsize\the\postindex
  799. %auxiliaries adapted from manmac
  800. \def\bluedoublecolumnout{%
  801. %Biased by manmac's doublecolumnout
  802.  \splittopskip=\topskip
  803.  \splitmaxdepth=\maxdepth \dimen@=25cm
  804.  \advance\dimen@ by-\ht\partialpage
  805.  \setbox0=\vsplit255 to\dimen@
  806.  \setbox2=\vsplit255 to\dimen@
  807.  \blueonepageout\pagesofar
  808.  \unvbox255 \penalty\outputpenalty}
  809. \def\blueonepageout#1{%
  810. %Biased by manmac's \onepageout
  811.  \shipout\vbox{%
  812.  \vbox to\baselineskip{\null
  813.          \the\headline\vss}%
  814.  \kern2ex
  815.  \vbox to\pageheight{#1}%
  816.  \kern1ex
  817.  \the\footline
  818.  }\advancepageno}
  819. !endverbatim
  820. The file name is parameterized in a token variable \cs{indexfile}.
  821. Default is |\indexfile{index.elm}|.
  822. A user can specify his own file via
  823. \thisverbatim{\emc}
  824. \beginverbatim
  825. \indexfile{<user index file>}
  826. !endverbatim
  827. \subhead{Running headlines.}
  828. The advanced mechanism of having the top entries
  829. and bottom entries appropriately represented
  830. in the headline has been treated In the \TeX book.
  831. Looking at the indexes
  832. of the \TeX book and the more recent Graphbase book,
  833. I noticed that Knuth did not use it.
  834. In Appendix D he states that the index is not
  835. tall enough to justify the mark mechanism.
  836. It is really advanced and subtle, and for those who
  837. are interested, please peruse the \TeX book.
  838. \head{Customization}
  839. A user might want to interfere at the places
  840. \bitem to include other tokens to be ignored while sorting\ftn{However,
  841.     in the Looking forward section this has been generalized into
  842.     the possibility to provide the control sequence with a sorting key.}
  843. \bitem to supply an ordering of his own
  844. \bitem to enrich the sorted and compressed file index.elm.
  845. \smallbreak
  846. \subhead{Adding tokens to be ignored.}
  847. In general we don't know what control sequences
  848. stand for.
  849. What are reasonable requirements to impose upon the handling of
  850. markup control sequences (cs for short)? In my opinion
  851. \bitem the cs must be defined
  852. \bitem \cs{makexref} writes the cs unexpanded
  853. \bitem ordering? unknown, and therefore neglected\ftn{However, see the
  854.    Looking forward section, ;-).}
  855. \bitem \cs{setupnxtokens} guards that the cs-s are written, unexpanded,
  856.        to index.srt and index.elm.
  857. \smallbreak
  858. As a consequence I decided to neglect the `in between'
  859. control sequences while sorting.
  860. For those who favour a one-pass job, I have provided the following,
  861. although it is simpler to add those control sequences to index.elm.
  862. The extension of the set of to be ignored tokens
  863. can be done via
  864. \beginverbatim
  865. \add#1to#2
  866. %for example adding to set of control
  867. %sequences
  868. \add\hfil to\conseqs
  869. %or control symbols
  870. \add\`to\consyms
  871. %Adding to the set of sort key pairs
  872. \add\hfil{hfil}to\srtkeypairs
  873. !endverbatim
  874. Each element  from \cs{conseqs}
  875. is redefined such that the control sequence
  876. token is written to the file with a space
  877. appended.\ftn{\cs{noexpand} is used
  878.   instead of \cs{string}.}
  879. \subhead{Modifying ordering.}
  880. The most general way is to `copy' the ordering table
  881. for modification.\ftn{My \cs{fifo} is just a short cut, which also
  882.    prevents typos in assigning the ASCII values. For \cs{fifo}, see
  883.    my `FIFO and LIFO sing the BLUes.'}
  884. \subsubhead{And what about a macro to add to the table?}
  885. This can be done easily, and superficially looks convenient
  886. for an innocent user.
  887. At the moment I don't trust the macros to be worthwhile
  888. for an innocent user, unless a very modest index has to be made.
  889. And this completes the circle: different ordering is not wanted, I guess.
  890. \subhead{Enriching the index.}
  891. This use is necessary when for example
  892. \bitem control sequences have to be typeset
  893. \bitem special symbols are needed, or
  894. \bitem cross-references within the index are required.
  895. \smallbreak\noindent
  896. The best way  is to start from the index.elm file.
  897. An example of use is that in
  898. the 4\TeX{} manual the index is sorted on 4TeX,
  899. but in the index a different representation is desired.
  900. (The control sequence
  901. \cs{fourtex} has been used for typesetting instead of 4TeX.)
  902. For that purpose the  file with IRs contains 4TeX and later this
  903. is substituted in the file index.elm by \cs{fourtex}.
  904. Another approach is to supply pairs of control sequences
  905. and sorting keys. See the Looking forward section.
  906. \subhead{Typesetting the enriched file.}
  907. When the default name is used---index.elm---just say \cs{pasteupindex}.
  908. For another file name  assign this name to the toks variable \cs{indexfile},
  909. prior to the invocation of \cs{pasteupindex}.
  910. \head{Tests}
  911. The macros have been tested on the file which was obtained from the
  912. \TeX book chapters 1 to 6. The (slightly adapted) file of raw IRs
  913. and the resulting sorted and compressed index entries have been included in
  914. the Appendices A and B.
  915. The test had to do with some 220 raw IRs.
  916. A driver program, which starts from a file of IRs
  917. not necessarily generated by manmac, is
  918. \beginverbatim
  919. \input blue.fmt
  920. %\irfile{erik.15b}    %file with 6 entries
  921. \irfile{erik.16b}     %file with 19 entries
  922. %\irfile{indexdat.610}%file with 183 entries
  923. %\irfile{erik.cgl}    %file with 228 entries
  924. \sortindex
  925. \pasteupindex
  926. !endverbatim
  927. Another test file was from the 4\TeX{} manual.
  928. This makeindex file consisted of roughly 760 entries
  929. of the form
  930. |\indexentry{...}{<number>}|.
  931. I first transformed this file---by \TeX{} :-)))---into a file obeying
  932. the IR syntax, via
  933. \beginverbatim
  934. \newwrite\erik
  935. \immediate\openout\erik=erik.cgl
  936. \def\indexentry#1#2{%
  937.  \immediate\write\erik{#1 !!0 #2.}}
  938. !endverbatim
  939. Then I  edited the file in order to
  940. \bitem remove the backslash(es) in the middle of the word part
  941. \bitem adjust IR type for control sequences (0 into 2)
  942.        such that the sorting et cetera went smooth.
  943. \smallbreak
  944. As result I obtained 343 sorted and compressed index entries.
  945. For typesetting some back substitutions had to be made
  946. \bitem in between backslashes inserted again
  947. \bitem the substitution/insertion of special control sequences.
  948. \smallbreak
  949. The total sorting time on my Mac Classic II was roughly 20 minutes,
  950. with 12200  IR comparisons, and 54149 words of memory used.\ftn{A
  951.    dummy job which just stores the IRs
  952.    but does not sort nor reduce the number of entries needed
  953.    34884 words of memory.}
  954. As format I used blue.fmt.\ftn{While proofing  this work,
  955.    it needs less hand work, because the control sequences can be accounted
  956.    for via sort key pairs. See the Looking forward section.}
  957. A final test was about copy with font changes and accents as
  958. part of the IRs. This file has been supplied  in the
  959. second example of this article.
  960. \head{Robustness}
  961. The weak point in this automated complicated process is
  962. the specification of the IRs. When wrong ones are supplied
  963. low-level \TeX{} error messages will emerge, and definitely
  964. will put off a user. My only remedy to this is
  965. \bitem don't hardly use markup within the IR
  966. \bitem don't use active charcters as part of the IR
  967. \bitem don't use \TeX{} special characters, especially
  968.        backslashes apart from a single control sequence (a type 2
  969.        IR.)
  970. \smallbreak\noindent %To locate errors
  971. I also print in the log file the number
  972. of elements to be sorted: n. This must be greater than zero.
  973. When n=0 is printed, the file of raw index entries is apparently empty,
  974. and 9 out of the 10 cases the asynchronous behaviour of the OTR is
  975. the cause, meaning that the file was already closed before
  976. it was written.
  977. When the file is empty, as argument of \cs{filetoarray}, a message is
  978. delivered in the log file.
  979. In the macros I have left some \cs{immediate}\cs{write}s, preceded by
  980. \%, which can be used to follow what is compared. This is handy
  981. when spotting an out of order IR.
  982. \head{Looking backward}
  983. It all started with sorting an array in SiB. In the early
  984. stage of this paper I adhered the model to allow writing IRs
  985. to a file and also, as option, to write directly to the array.
  986. Because of the latter, I had to modify the OTR such that
  987. the array elements were extended with page numbers.
  988. I used the mark mechanism and it worked.\ftn{However there
  989.    was still a detail to be fixed: the first mark was also
  990.    written in the main vertical list.}
  991. I abandonned this option for simplicity reasons. When restricted
  992. to writing to a file a reader does not have to bother about the OTR,
  993. and no redefinitions of the array elements are needed.
  994. A price I had to pay for flexibility is the
  995. generation of  the replacement texts for control sequences to be
  996. ignored, each time in every invocation of \cs{makexref}.
  997. Another `inefficiency' is the `generation' of the ordering table.
  998. Perhaps, I should just have included the `tables' as such instead.
  999. A final point is the general conflict with control sequences
  1000. already in use.
  1001. \head{Looking forward}
  1002. Is it realistic to expect that there will be another user besides me?
  1003. I don't think so, because history has it that
  1004. manmac as such has been neglected at large,
  1005. and I don't see
  1006. why people would nevertheless prefer my work,
  1007. which is so intimately connected to manmac.
  1008. Whatever the future has in store, let us go on.
  1009. \subhead{Subsidiary entries.}
  1010. What are the requirements for this?
  1011. Let us assume that the markup for a subsidiary entry starts with \cs{sub}.
  1012. IMHO the following specs are relevant
  1013. \bitem \cs{sub} should be neglected in the copy
  1014. \bitem write \cs{sub} as string to the file index
  1015. \bitem neglect \cs{sub} while sorting
  1016. \bitem `reduce' entries which differ in subentries
  1017.        by suppressing the main entry except for the first time,
  1018.        while typesetting the index element
  1019. \bitem indent the subsidiary entry by
  1020.        \cs{parindent} while typesetting.
  1021. \smallbreak\noindent
  1022. The above specs can be realized as follows
  1023. \bitem |\let\sub=\relax|
  1024. \bitem include \cs{sub} in \cs{conseqs}
  1025. \bitem the reduce problem is similar to the typesetting of references,
  1026.        where  the author part is printed once for different publications.
  1027.        I found that in \AmSTeX, and used it in `BLUe's References.'
  1028. \bitem add |\let\sub=\endgraf| in \cs{pasteupreferences}.
  1029. \smallbreak\noindent
  1030. Actually, the above has been incorporated in blue.fmt.
  1031. \subhead{Sorting keys.}
  1032. So far we have mostly neglected tokens while sorting.
  1033. But, \dots is it do-able to sort each control
  1034. sequence according to a sorting key?
  1035. This comes down to
  1036. \bitem provide a way to specify for
  1037.        sorting key pairs, that is pairs of a control sequence
  1038.        and its sorting key
  1039. \bitem sort on the sorting key
  1040. \bitem set the index entries with the embedded
  1041.        control sequences according to their definitions.
  1042. %\smallbreak
  1043. \example{Use of sorting keys}
  1044. Suppose that we have
  1045. \beginverbatim
  1046. \add\fourtex{4tex}to\srtkeypairs
  1047. \add\fourtex to\srtkeys
  1048. %\setupsrtkeys
  1049. Copy with ^{IR \fourtex}
  1050. \sortindex %with 4tex for \fourtex
  1051. \pasteindex%Set `IR \fourtex{} <pagenumbers>'
  1052. !endverbatim
  1053. \noindent then the file index will contain the IR
  1054. \thisverbatim{\catcode`\!=12 \emc
  1055.               \catcode`\;=0 }
  1056. \beginverbatim
  1057. IR \fourtex{} !0 <pageno>
  1058. ;endverbatim\noindent
  1059. The above will be sorted on 4tex.
  1060. The key issue in the implementation is to extend
  1061. \cs{nxtwindex} by the test \cs{pophead}$\in$ \cs{srtkeys}.
  1062. If the test yields true sort further on  |<sorting key><tail>|,
  1063. that is insert the sorting key.
  1064. Actually the above has been included in blue.fmt with as defaults
  1065. \beginverbatim
  1066. \conseqs{\c\space\bf\it\rm\tt\sub\relax}
  1067. \consyms{\`\'\"\^\~}
  1068. \srtkeypairs{\TeX{tex}
  1069.              \LaTeX{latex}
  1070.              \AmSTeX{amstex}}
  1071. \srtkeys{\TeX\LaTeX\AmSTeX}
  1072. !endverbatim\noindent
  1073. In order to use this nice feature extend the script as follows
  1074. \beginverbatim
  1075. \add...to\srtkeypairs%one or more pairs
  1076. \setupsrtkeys        %extends the set of
  1077.                      %sort keys
  1078. ...%copy proper
  1079. \sortindex
  1080. \pasteupindex
  1081. !endverbatim\noindent
  1082. The last issue of suppressing the main word with multiple sub entries
  1083. can be implemented too. For the moment I refrained, and will wait
  1084. for user action.
  1085. \head{Availability}
  1086. The macros are released in the public domain as part of blue.fmt,
  1087. version November 1994.
  1088. Needed from manmac are the IR macros, |^| and its auxiliaries,
  1089. next to some macros for handling the doublecolumns, for example
  1090. \cs{balancecolumns}. Some macros from SiB are used too, especially
  1091. the sorting macros.
  1092. An easy way is to include blue.fmt, which contains them all.
  1093. \head{Acknowledgements}
  1094. Erik Frambach thank you for the file of 4\TeX, your
  1095. assitance, and your sound judgement.
  1096. As usual Jos Winnink helped me
  1097. again to procruste the markup of the article
  1098. into maps.sty.
  1099. \head{Conclusion}
  1100. The macros work smoothly for
  1101. a modest and practical index.
  1102. I intend to  use the macros in the near future for my
  1103. `Publishing with \TeX' booklet.
  1104. The macros serve an educational purpose,
  1105. and  stimulate thinking.
  1106. My added value to manmac is, that a modest index can be
  1107. processed in a one-pass job. More complex indexes
  1108. can be processed via a proof run, editing of index.elm,
  1109. and a final run with index.elm inserted as copy.
  1110. For a foolproof approach it is necessary to
  1111. look ahead for general tokens.
  1112. The problem is that we can't account for all the
  1113. control sequences or active characters to be used.
  1114. For indexes of modest complexity my limited
  1115. approach is  good enough.
  1116. The bonus is simplicity throughout.
  1117. In general it is difficult to know when to stop,
  1118. as Schumacher in his precious `Small is beautiful'
  1119. already pointed out.
  1120. My case rest.
  1121. \pasteupreferences
  1122. \newcol
  1123. \head{Appendix A: File of raw IRs from the \TeX book}
  1124. \thisverbatim{\catcode`\~=0
  1125.    \catcode`\!=12
  1126. \beginverbatim
  1127. %Entries with non-monotone page numbers have
  1128. %been added to enforce range representation.
  1129. tau !2 1.
  1130. epsilon !2 1.
  1131. chi !2 2.
  1132. chi !2 1.
  1133. beauty !0 1.
  1134. logo !0 1.
  1135. TEX !0 1.
  1136. Honeywell Information Systems !0 1.
  1137. Bemer, Robert, see TEX, ASCII !0 1.
  1138. TeX !1 1.
  1139. PLATO !0 2.
  1140. BACON !0 2.
  1141. quotation marks !0 3.
  1142. ASCII !0 3.
  1143. apostrophe !0 3.
  1144. blank space !0 3.
  1145. dashes !0 3.
  1146. hyphens !0 3.
  1147. minus signs !0 3.
  1148. En-dash !0 3.
  1149. En-dash !0 2.
  1150. Em-dash !0 5.
  1151. bibliography !0 4.
  1152. ligatures !0 4.
  1153. ligatures !0 3.
  1154. kerning !0 4.
  1155. dangerous bend !0 4.
  1156. lq !2 4.
  1157. rq !2 4.
  1158. quotes within quotes !0 4.
  1159. thinspace !2 4.
  1160. , !2 4.
  1161. SWIFT !0 5.
  1162. JEVONS !0 5.
  1163. escape character !0 6.
  1164. backslash !0 6.
  1165. control sequences !0 6.
  1166. markup commands, see control sequences !0 6.
  1167. input !2 6.
  1168. Polya !0 6.
  1169. Szego !0 6.
  1170. acute !0 6.
  1171. umlaut !0 6.
  1172. ' !0 6.
  1173. " !0 6.
  1174. accents !0 6.
  1175. accents !0 4.
  1176. accents !0 5.
  1177. control word !0 6.
  1178. letter !0 6.
  1179. control symbol !0 6.
  1180. space !0 6.
  1181. * !2 6.
  1182. <return> !2 7.
  1183. <tab> !2 7.
  1184. carriage-return, see <return> !0 7.
  1185. logo !0 7.
  1186. TeX !2 7.
  1187. pi !2 7.
  1188. Pi !2 7.
  1189. aleph !2 7.
  1190. infty !2 7.
  1191. le !2 7.
  1192. ge !2 7.
  1193. ne !2 7.
  1194. oplus !2 7.
  1195. otimes !2 7.
  1196. uppercase !0 7.
  1197. lowercase !0 7.
  1198. primitive !0 7.
  1199. input !2 7.
  1200. ' !2 7.
  1201. " !2 7.
  1202. accent !2 7.
  1203. exercise !2 8.
  1204. show !2 8.
  1205. thinspace !2 8.
  1206. kern !2 8.
  1207. log file !0 8.
  1208. SELDEN !0 9.
  1209. LINCOLN !0 9.
  1210. typeface !0 10.
  1211. bold !0 10.
  1212. fonts !0 10.
  1213. rm !2 10.
  1214. sl !2 10.
  1215. it !2 10.
  1216. tt !2 10.
  1217. bf !2 10.
  1218. typewriter type !0 10.
  1219. face !0 10.
  1220. roman type !0 10.
  1221. oblique !0 10.
  1222. Slanted type !0 10.
  1223. italic type !0 10.
  1224. curly brace !0 10.
  1225. brace !0 10.
  1226. grouping !0 10.
  1227. Dieter !0 10.
  1228. / !2 10.
  1229. El\`eve !0 10.
  1230. punctuation !0 11.
  1231. nullfont !2 11.
  1232. points !0 11.
  1233. dangerous bend !0 11.
  1234. subscripts !0 11.
  1235. tenrm !2 11.
  1236. ninerm !2 11.
  1237. tensl !2 11.
  1238. ninesl !2 11.
  1239. baseline !0 11.
  1240. tenpoint !2 11.
  1241. ninepoint !2 11.
  1242. Computer Modern !0 12.
  1243. cm fonts !0 12.
  1244. font !2 12.
  1245. design size !0 12.
  1246. at !1 12.
  1247. magnification !0 12.
  1248. reduction !0 12.
  1249. cmr5 !1 12.
  1250. piano !0 12.
  1251. magstep !2 12.
  1252. magstephalf !2 12.
  1253. magnification !2 12.
  1254. LEE !0 13.
  1255. SHAKESPEARE !0 13.
  1256. grouping characters !0 14.
  1257. curly braces, see braces !0 14.
  1258. block structure !0 14.
  1259. local !0 14.
  1260. TeX !2 14.
  1261. space !0 14.
  1262. empty group !0 14.
  1263. lbrace rbrace !0 14.
  1264. ligature !0 14.
  1265. control space !0 14.
  1266. centerline !2 14.
  1267. nested !0 14.
  1268. global !2 15.
  1269. page number !0 15.
  1270. Output routines !0 15.
  1271. advance !2 15.
  1272. begingroup !2 15.
  1273. endgroup !2 15.
  1274. nested groups !0 15.
  1275. MUIRHEAD !0 16.
  1276. HOWARD !0 16.
  1277. Running the program !0 17.
  1278. ** !1 17.
  1279. relax !2 17.
  1280. return !3 17.
  1281. asterisk !0 17.
  1282. end !2 17.
  1283. [1] !1 17.
  1284. texput !1 17.
  1285. dvi !1 17.
  1286. device independent !0 17.
  1287. story\period{}tex !1 17.
  1288. hrule !2 17.
  1289. vskip !2 17.
  1290. eject !2 17.
  1291. rule !0 18.
  1292. paragraphs !0 18.
  1293. blank line !0 18.
  1294. empty line !0 18.
  1295. umlaut !0 18.
  1296. cedilla !0 18.
  1297. ties !0 18.
  1298. tilde !0 18.
  1299. vfill !2 18.
  1300. eject !2 18.
  1301. file names !0 18.
  1302. ** !1 18.
  1303. * !1 18.
  1304. input !2 18.
  1305. ampersand !0 18.
  1306. format file !0 18.
  1307. preloaded formats !0 18.
  1308. end !2 19.
  1309. percent !0 19.
  1310. comments !0 19.
  1311. hsize !2 19.
  1312. input !2 19.
  1313. overfull box !0 19.
  1314. [] !1 20.
  1315. r\'esum\'e{} !0 253.
  1316. leading, see vskip !0 17.
  1317. centerline !2 17.
  1318. Thor !0 17.
  1319. " !2 17.
  1320. c !2 17.
  1321. Drofnats !0 17.
  1322. vfill !2 17.
  1323. transcript !0 20.
  1324. log file !0 20.
  1325. hyphenation !0 20.
  1326. discretionary hyphens !0 20.
  1327. badness !0 20.
  1328. tolerance !2 21.
  1329. hbadness !2 21.
  1330. underfull box !0 21.
  1331. column width !0 21.
  1332. measure, see hsize !0 21.
  1333. raggedright !2 21.
  1334. breaking a paragraph !0 21.
  1335. hfuzz !2 21.
  1336. dash !2 21.
  1337. error messages !0 21.
  1338. ? !1 22.
  1339. italic correction !0 10.
  1340. inserting text online !0 22.
  1341. online interaction, see interaction !0 22.
  1342. interacting with TeX !0 22.
  1343. deleting tokens !0 22.
  1344. help messages !0 23.
  1345. scrollmode !2 23.
  1346. nonstopmode !2 23.
  1347. batchmode !2 23.
  1348. errorstopmode !2 23.
  1349. interrupt !0 23.
  1350. argument !0 23.
  1351. centerline !2 23.
  1352. editing !0 24.
  1353. errorcontextlines !2 24.
  1354. ARISTOTLE !0 25.
  1355. HABAKKUK !0 25.
  1356. COWPER !0 25.
  1357. ~endverbatim
  1358. \newcol
  1359. \head{Appendix B: Index}
  1360. The index below has been typeset via
  1361. \thisverbatim{\catcode`\!=12
  1362.     \catcode`\~=0 }
  1363. \beginverbatim
  1364. {\obeylines\gdef\typindentry#1
  1365.  {%#1 an IR as such
  1366.  \if!#1!\expandafter\egroup\else%
  1367.  \splitintoks#1%
  1368.  \ifcase\digit{\the\indword}\or%
  1369.          {\tt\the\indword}\or%
  1370.   {\tt\char92\hbox{\the\indword}}\or%
  1371.   $\langle\hbox{\the\indword}\rangle$\fi{} %
  1372.   \pagenrs.\fi\par}
  1373. \bgroup\def\par{\endgraf \typindentry}
  1374. \obeylines
  1375. ' !0{} 6.
  1376. ' !2{} 7.
  1377. ~endverbatim
  1378. \subhead{Index.}
  1379. {\obeylines\gdef\typindentry#1
  1380.  {%#1 a IR
  1381.  \if!#1!\expandafter\egroup\else%
  1382.  \splitintoks#1%
  1383.  \ifcase\digit\the\indword\or%
  1384.          {\tt\the\indword}\or%
  1385.   {\tt\char92\the\indword}\or%
  1386.   $\langle\hbox{\the\indword}\rangle$\fi{} %
  1387.   \pagenrs.\fi\par}
  1388. \bgroup\def\par{\endgraf \typindentry}
  1389. \obeylines
  1390. ' !0{} 6.
  1391. ' !2{} 7.
  1392. " !0{} 6.
  1393. " !2{} 7, 17.
  1394. * !1{} 18.
  1395. * !2{} 6.
  1396. ** !1{} 17, 18.
  1397. , !2{} 4.
  1398. [] !1{} 20.
  1399. [1] !1{} 17.
  1400. / !2{} 10.
  1401. ? !1{} 22.
  1402. accent !2{} 7.
  1403. accents !0{} 4--6.
  1404. acute !0{} 6.
  1405. advance !2{} 15.
  1406. aleph !2{} 7.
  1407. ampersand !0{} 18.
  1408. apostrophe !0{} 3.
  1409. argument !0{} 23.
  1410. ARISTOTLE !0{} 25.
  1411. ASCII !0{} 3.
  1412. asterisk !0{} 17.
  1413. at !1{} 12.
  1414. backslash !0{} 6.
  1415. BACON !0{} 2.
  1416. badness !0{} 20.
  1417. baseline !0{} 11.
  1418. batchmode !2{} 23.
  1419. beauty !0{} 1.
  1420. begingroup !2{} 15.
  1421. Bemer, Robert, see TEX, ASCII !0{} 1.
  1422. bf !2{} 10.
  1423. bibliography !0{} 4.
  1424. blank line !0{} 18.
  1425. blank space !0{} 3.
  1426. block structure !0{} 14.
  1427. bold !0{} 10.
  1428. brace !0{} 10.
  1429. breaking a paragraph !0{} 21.
  1430. c !2{} 17.
  1431. carriage-return, see $\langle$return$\rangle$ !0{} 7.
  1432. cedilla !0{} 18.
  1433. centerline !2{} 14, 17, 23.
  1434. chi !2{} 1, 2.
  1435. cm fonts !0{} 12.
  1436. cmr5 !1{} 12.
  1437. column width !0{} 21.
  1438. comments !0{} 19.
  1439. Computer Modern !0{} 12.
  1440. control sequences !0{} 6.
  1441. control space !0{} 14.
  1442. control symbol !0{} 6.
  1443. control word !0{} 6.
  1444. COWPER !0{} 25.
  1445. curly brace !0{} 10.
  1446. curly braces, see braces !0{} 14.
  1447. dangerous bend !0{} 4, 11.
  1448. dash !2{} 21.
  1449. dashes !0{} 3.
  1450. deleting tokens !0{} 22.
  1451. design size !0{} 12.
  1452. device independent !0{} 17.
  1453. Dieter !0{} 10.
  1454. discretionary hyphens !0{} 20.
  1455. Drofnats !0{} 17.
  1456. dvi !1{} 17.
  1457. editing !0{} 24.
  1458. eject !2{} 17, 18.
  1459. El{\accent 18 e}ve !0{} 1.
  1460. Em-dash !0{} 5.
  1461. empty group !0{} 14.
  1462. empty line !0{} 18.
  1463. En-dash !0{} 2, 3.
  1464. end !2{} 17, 19.
  1465. endgroup !2{} 15.
  1466. epsilon !2{} 1.
  1467. errorcontextlines !2{} 24.
  1468. error messages !0{} 21.
  1469. errorstopmode !2{} 23.
  1470. escape character !0{} 6.
  1471. exercise !2{} 8.
  1472. face !0{} 10.
  1473. file names !0{} 18.
  1474. font !2{} 12.
  1475. fonts !0{} 10.
  1476. format file !0{} 18.
  1477. ge !2{} 7.
  1478. global !2{} 15.
  1479. grouping !0{} 10.
  1480. grouping characters !0{} 14.
  1481. HABAKKUK !0{} 25.
  1482. hbadness !2{} 21.
  1483. help messages !0{} 23.
  1484. hfuzz !2{} 21.
  1485. Honeywell Information Systems !0{} 1.
  1486. HOWARD !0{} 16.
  1487. hrule !2{} 17.
  1488. hsize !2{} 19.
  1489. hyphenation !0{} 20.
  1490. hyphens !0{} 3.
  1491. infty !2{} 7.
  1492. input !2{} 6, 7, 18, 19.
  1493. inserting text online !0{} 22.
  1494. interacting with TeX !0{} 22.
  1495. interrupt !0{} 23.
  1496. it !2{} 10.
  1497. italic correction !0{} 10.
  1498. italic type !0{} 10.
  1499. JEVONS !0{} 5.
  1500. kern !2{} 8.
  1501. kerning !0{} 4.
  1502. lbrace rbrace !0{} 14.
  1503. le !2{} 7.
  1504. leading, see vskip !0{} 17.
  1505. LEE !0{} 13.
  1506. letter !0{} 6.
  1507. ligature !0{} 14.
  1508. ligatures !0{} 3, 4.
  1509. LINCOLN !0{} 9.
  1510. local !0{} 14.
  1511. log file !0{} 8, 20.
  1512. logo !0{} 1, 7.
  1513. lowercase !0{} 7.
  1514. lq !2{} 4.
  1515. magnification !0{} 12.
  1516. magnification !2{} 12.
  1517. magstep !2{} 12.
  1518. magstephalf !2{} 12.
  1519. markup commands, see control sequences !0{} 6.
  1520. measure, see hsize !0{} 21.
  1521. minus signs !0{} 3.
  1522. MUIRHEAD !0{} 16.
  1523. ne !2{} 7.
  1524. nested !0{} 14.
  1525. nested groups !0{} 15.
  1526. ninepoint !2{} 11.
  1527. ninerm !2{} 11.
  1528. ninesl !2{} 11.
  1529. nonstopmode !2{} 23.
  1530. nullfont !2{} 11.
  1531. oblique !0{} 10.
  1532. online interaction, see interaction !0{} 22.
  1533. oplus !2{} 7.
  1534. otimes !2{} 7.
  1535. Output routines !0{} 15.
  1536. overfull box !0{} 19.
  1537. page number !0{} 15.
  1538. paragraphs !0{} 18.
  1539. percent !0{} 19.
  1540. Pi !2{} 7.
  1541. pi !2{} 7.
  1542. piano !0{} 12.
  1543. PLATO !0{} 2.
  1544. points !0{} 11.
  1545. Polya !0{} 6.
  1546. preloaded formats !0{} 18.
  1547. primitive !0{} 7.
  1548. punctuation !0{} 11.
  1549. quotation marks !0{} 3.
  1550. quotes within quotes !0{} 4.
  1551. raggedright !2{} 21.
  1552. reduction !0{} 12.
  1553. relax !2{} 17.
  1554. r{\accent 19 e}sum{\accent 19 e}{} !0{} 253.
  1555. return !3{} 17.
  1556. \<return> !2{} 7.
  1557. rm !2{} 10.
  1558. roman type !0{} 10.
  1559. rq !2{} 4.
  1560. rule !0{} 18.
  1561. Running the program !0{} 17.
  1562. scrollmode !2{} 23.
  1563. SELDEN !0{} 9.
  1564. SHAKESPEARE !0{} 13.
  1565. show !2{} 8.
  1566. sl !2{} 10.
  1567. Slanted type !0{} 10.
  1568. space !0{} 6, 14.
  1569. story.{}tex !1{} 17.
  1570. subscripts !0{} 11.
  1571. SWIFT !0{} 5.
  1572. Szego !0{} 6.
  1573. <tab> !2{} 7.
  1574. tau !2{} 1.
  1575. tenpoint !2{} 11.
  1576. tenrm !2{} 11.
  1577. tensl !2{} 11.
  1578. TEX !0{} 1.
  1579. TeX !1{} 1.
  1580. TeX !2{} 7, 14.
  1581. texput !1{} 17.
  1582. thinspace !2{} 4, 8.
  1583. Thor !0{} 17.
  1584. ties !0{} 18.
  1585. tilde !0{} 18.
  1586. tolerance !2{} 21.
  1587. transcript !0{} 20.
  1588. tt !2{} 10.
  1589. typeface !0{} 10.
  1590. typewriter type !0{} 10.
  1591. umlaut !0{} 6, 18.
  1592. underfull box !0{} 21.
  1593. uppercase !0{} 7.
  1594. vfill !2{} 17, 18.
  1595. vskip !2{} 17.
  1596. \newcol
  1597. \head{Appendix C: The index macros}
  1598. Macros from blue.fmt (and manmac) are needed.
  1599. Those have not been included.
  1600. \thisverbatim{\numvrb
  1601.               \catcode`\<=12
  1602.               \catcode`\!=12
  1603.               \catcode`\|=12
  1604.               \catcode`\;=0
  1605. \beginverbatim
  1606. %From BLUe's Index                Oct 94%;numvrb
  1607. %Some unused macros are left in.
  1608. \newread\inxin
  1609. \newtoks\indword
  1610. \newtoks\indexfile
  1611.    %To parameterize the resulting index
  1612. \newtoks\irfile
  1613.    %To parameterize the IRs
  1614. \newtoks\indexname
  1615. \newtoks\preindex
  1616. \newtoks\postindex
  1617. \newtoks\conseqs
  1618. \newtoks\consyms
  1619. \newtoks\srtkeys
  1620. \newtoks\srtkeypairs
  1621. \newtoks\ignores
  1622. %Initializations
  1623. \proofmodetrue
  1624. \irfile{index}
  1625. \indexfile{index.elm}
  1626. \indexname{Index}
  1627. \preindex{\head{\the\indexname}}
  1628. \postindex{}
  1629. \immediate\openout\inx=index
  1630. \conseqs{\c\space\bf\it\rm\tt
  1631.    \sub\relax}
  1632. \consyms{\`\'\"\^\~}
  1633. \srtkeypairs{\TeX{tex}
  1634.              \LaTeX{latex}
  1635.              \AmSTeX{amstex}}
  1636. \srtkeys{\TeX\LaTeX\AmSTeX}
  1637. \let\sub\relax
  1638. %Macros
  1639. %User level
  1640. %;vrblin=100
  1641. \def\sortindex{%Nov 1994, cgl
  1642. %Purpose:
  1643. %To sort IR file.
  1644. %Input: default index is sorted
  1645. %      ( file specified in \irfile)
  1646. %Output: file index.elm.
  1647.    \newpage\immediate\closeout\inx
  1648.    \filetoarray{\the\irfile}
  1649.    \immediate\write16{Sorting n=\the\n.
  1650.       Please wait, O(nlog n) process.}
  1651.    \let\cmp\cmpir\let\nxtw\nxtwindex
  1652.    \otindex\let\ \space
  1653.    {%Make sortkey defs
  1654.     \ea\sokdef\the\skpairs\fedkos\relax
  1655.    \sort
  1656.    {\let\spaceseparator\space
  1657.    \setupnxtokens\def\ {\nx\ }%
  1658.    \immediate\write16{Range reduction.}
  1659.    \redrngtofile{index.srt}
  1660.    \immediate\write16{After reduction and
  1661.     writing to file index.srt; n=\the\n.}
  1662.    \immediate\write16{Transform
  1663.          index.srt-->index.elm.}
  1664.    \tawfiletofile{index.srt}{\the
  1665.                   \indexfile}}}
  1666. %Set up set of \srtkeys
  1667. \def\setupsrtkeys{\ea
  1668.  \sok\the\srtkeypairs\kos\relax}
  1669. %;vrblin=150
  1670. \def\pasteupindex{%Nov 1994, cgl
  1671. %Purpose:
  1672. %To set index in (balanced) doublecolumn.
  1673. %The index is preceded by contents of
  1674. %\preindex and followed by contents of
  1675. %\postindex.
  1676. %Input: default index.elm is set
  1677. %       (file specified in \indexfile).
  1678. %Biased by manmac's \begindoublecolumns
  1679.  \newpage \begingroup
  1680.  \def\space{{\tt\char32 }}%
  1681.  \the\preindex\par
  1682.  \pageheight\vsize
  1683.  \pagewidth\pagewd%anachronism
  1684.  \parindent1em
  1685.  \output={\global\setbox\partialpage=
  1686.   \vbox{\unvbox255\bigskip}}%
  1687.  \eject
  1688.  \output={\bluedoublecolumnout}%
  1689.  \hsize=8.5cm \vsize=51cm%blue.fmt values
  1690.  \parskip0pt plus.8pt\relax
  1691.  \obeylines\everypar{%
  1692.     \hangindent2\parindent}%
  1693.  \let\par\endgraf
  1694.  \let\sub\endgraf
  1695.  \input\the\indexfile\relax
  1696. %endpasteupindex part biased by
  1697. %manmac's \enddoublecolumns
  1698.  \output={\balancecolumns}\eject
  1699.  \endgroup
  1700.  \pagegoal=\vsize\the\postindex}
  1701. %Add an element #1 to toks var #2
  1702. \def\add#1to#2{#2\ea{\the#2#1}}
  1703. %Inner level
  1704. %IR creation
  1705. %;vrblin=200
  1706. \def\makexref{\ifproofmode%Mod cgl oct 94
  1707.  \bgroup\def\ {\string\ }%
  1708.  \def\process##1{\def##1{\string##1 }}%
  1709.   \ea\ea\ea\fifo\ea\the\ea\conseqs
  1710.                 \the\srtkeys\ofif
  1711.  \def\process##1{\def##1{\string##1}}%
  1712.  \ea\fifo\the\consyms\ofif
  1713.  \xdef\writeit{\write\inx{\text{}
  1714.     !\xreftype\spaceseparator
  1715.     \nx\number\pageno.}}\writeit
  1716.  \egroup
  1717.  \else\ifhmode\kern0pt\fi\fi
  1718.  \ifsilent\ignorespaces\else{\next}\fi
  1719. %Sorting
  1720. %;vrblin=250
  1721. \def\cmpir#1#2{%#1, #2 defs
  1722. %Result: \status= 0, 1, 2 if
  1723. %        \val{#1} =, >, < \val{#2}
  1724. %\immediate\write16{Compared are: *#1*
  1725. %                   and *#2*}%
  1726. \ea\ea\ea\decom\ea#1#2}
  1727. \def\nxtwindex#1#2{%
  1728. %Function:
  1729. %On input: #1 contains the `word'
  1730. %As result: #2 contains the value
  1731. %   of the first non-ignored token as given
  1732. %   in the ordering table.
  1733. %#1 contains the rest of the `word'
  1734.  \def\pop##1##2\pop{%
  1735.  \gdef#1{##2}\def\pophead{##1}}%head and tail
  1736.  \ea\pop#1\pop%split in head and tail
  1737.  \ignores\ea\ea\ea{\ea
  1738.   \the\ea\conseqs\the\consyms}%
  1739.  \ea\loc\pophead{\the\ignores}%
  1740.  \iffound\ifx\empty#1 \chardef#2=0
  1741.          \else\nxtwindex#1#2 \fi
  1742.  \else
  1743.  \ea\loc\pophead{\the\srtkeys}%
  1744.   \iffound\xdef\pophead{\pophead}%
  1745.     \ea\ea\ea\gdef\ea\ea\ea#1\ea\ea\ea
  1746.       {\ea\pophead#1}%
  1747.     \nxtwindex#1#2
  1748.   \else
  1749.   \ea\let\ea#2\csname ot\pophead\endcsname
  1750.   \fi
  1751.  \fi}
  1752. \def\otindex{%Parameters: Ordering `table'
  1753. %Special cases
  1754. \ea\chardef\csname ot \endcsname=0
  1755. \ea\chardef\csname ot\space\endcsname=0
  1756. %{|}~(\char126) in ASCII after lowercase
  1757. %^ active character
  1758. %Bulk according to ACII
  1759. \def\process##1{\ea\chardef
  1760.    \csname ot##1\endcsname=`##1 }
  1761. %lowercase letters
  1762. \fifo abcdefghijklmnopqrstuvwxyz\ofif
  1763. \chardef\otij=`y \chardef\otIJ=`y
  1764. %other characters
  1765. \fifo !"##$&'()*+,-./0123456789:;<=>?@
  1766.       []_`\ofif
  1767. %uppercase letters equal lowercase
  1768. \def\process##1{\ea\chardef
  1769.   \csname ot##1\endcsname=\lccode`##1 }
  1770. \uppercase{\fifo
  1771.   abcdefghijklmnopqrstuvwxyz\ofif}
  1772. %Range reduction
  1773. %;vrblin=400
  1774. \def\redrngtofile#1{%Reduction of \1,...,\n,
  1775. %with range representation of page numbers
  1776. \immediate\openout\inx=#1
  1777.  {\k1\kk0 \ifnum\n>0
  1778.  \ea\ea\ea\splitwn\csname\the\k\endcsname
  1779.  \let\refer\word
  1780.  \let\nrsrng\empty\prcrng\num\fi
  1781.  \loop\ifnum\k<\n\advance\k1
  1782.   \ea\ea\ea\splitwn\csname\the\k\endcsname
  1783.   \ifx\refer\word%extend \nrsrng with number
  1784.     \prcrng\num
  1785.   \else%write record to \kk
  1786.    \advance\kk1 \strnrs
  1787.    \immediate\write\inx{\refer\spaceseparator
  1788.       \nrsrng.}%
  1789.    \let\nrsrng\empty\init\num
  1790.    \prcrng\num\let\refer\word
  1791.   \fi
  1792.  \repeat\ifnum1<\n
  1793.   \advance\kk1 \strnrs
  1794.   \immediate\write\inx{\refer\spaceseparator
  1795.     \nrsrng.}%
  1796.  \global\n\kk\fi
  1797.  }\immediate\closeout\inx}
  1798. %Copying
  1799. %;vrblin=500
  1800. \def\filetoarray#1{%#1 is file name
  1801.  \immediate\openin\inxin=#1\relax
  1802.  \ifeof\inxin\immediate\write16{File #1 empty
  1803.    or non-existent.}%
  1804.  \fi \n\kzero\continuetrue
  1805.  \loop\ifeof\inxin\continuefalse\fi
  1806.  \ifcontinue\advance\n1 \immediate
  1807.  \read\inxin t\ea o\csname\the\n\endcsname
  1808. %\immediate\write16{k: \number\n:
  1809. %     \csname\the\n\endcsname}%
  1810.  \repeat\advance\n-1
  1811.  \immediate\closein\inxin}
  1812. \def\tawfiletofile#1#2{\continuetrue
  1813.  \immediate\openin\inxin=#1\relax
  1814.  \immediate\openout\inx=#2\relax
  1815.  \loop\read\inxin to\IR
  1816.    \ifeof\inxin\continuefalse\fi
  1817.  \ifcontinue\trfandwrite\IR
  1818.  \repeat
  1819.  \immediate\closein\inxin
  1820.  \immediate\closeout\inx
  1821. \def\setupnxtokens{%
  1822.  \def\process##1{\def##1{\nx##1}}%
  1823.   \ea\ea\ea\fifo\ea\the\ea\conseqs
  1824.                 \the\srtkeys\ofif
  1825.  \def\process##1{\def##1{\string##1}}%
  1826.  \ea\fifo\the\consyms\ofif
  1827. \def\trfandwrite#1{\ea\splitintoks#1%
  1828.  \immediate\write\inx{\nx\noindent
  1829.   \ifcase\digit{\the\indword}\or
  1830.    {\nx\tt\the\indword}\or
  1831.    {\nx\tt\char92\hbox{\the\indword}}\or
  1832.    $\nx\langle\hbox{\the\indword}\nx\rangle
  1833.     $\fi\spaceseparator\pagenrs.}}
  1834. \def\splitintoks#1 !#2 #3.{\indword{#1}%
  1835.   \chardef\digit=#2\relax\def\pagenrs{#3}}
  1836. %Typesetting;vrblin=600
  1837. \def\bluedoublecolumnout{%
  1838. %Biased by manmac's doublecolumnout
  1839.  \splittopskip=\topskip
  1840.  \splitmaxdepth=\maxdepth \dimen@=25cm
  1841.  \advance\dimen@ by-\ht\partialpage
  1842.  \setbox0=\vsplit255 to\dimen@
  1843.  \setbox2=\vsplit255 to\dimen@
  1844.  \blueonepageout\pagesofar
  1845.  \unvbox255 \penalty\outputpenalty}
  1846. \def\blueonepageout#1{%
  1847. %Biased by manmac's \onepageout
  1848.  \shipout\vbox{%
  1849.  \vbox to\baselineskip{\null
  1850.          \the\headline\vss}%
  1851.  \kern2ex
  1852.  \vbox to \pageheight{#1}%
  1853.  \kern1ex
  1854.  \the\footline
  1855.  }\advancepageno}
  1856. %Auxiliaries
  1857. %SetOfKeys;vrblin=700
  1858. \def\sok#1#2{%Function:
  1859. %Build from \srtkeypairs \srtkeys
  1860. %via \ea\sok\srtkeypairs\kos\relax
  1861. \ifx#1\kos\kos\fi
  1862.   \srtkeys\ea{\the\srtkeys#1}\sok}
  1863. \def\kos#1\sok{\fi}
  1864. \def\sokdef#1#2{%Function:
  1865. %Build from \skpairs srtkey defs
  1866. \ifx#1\fedkos\fedkos\fi
  1867.   \def#1{#2}\sokdef}
  1868. \def\fedkos#1\sokdef{\fi}
  1869. %;nonum
  1870. %Table of contents: blue.ind
  1871. %Variables
  1872. %   \indexname................8, 19
  1873. %   \preindex.................9, 20
  1874. %   \postindex................10, 21
  1875. %   \indword..................3
  1876. %   \indexfile................4, 19
  1877. %   \irfile...................6, 18
  1878. %   \conseqs..................11, 24-25
  1879. %   \consyms..................12, 26
  1880. %   \srtkeys..................13, 30
  1881. %   \srtkeypairs..............14, 28-29
  1882. %   \ignores..................15
  1883. %User level macros
  1884. %   \sortindex................101-125
  1885. %   \pasteupindex.............151-183
  1886. %   \add#1to#2................186
  1887. %   \setupsrtkeys.............127-129
  1888. %Lower level macros
  1889. %IR Creation
  1890. %   \makexref.................201-214
  1891. %Sorting
  1892. %   \cmpir....................251-256
  1893. %   \nxtwindex................258-282
  1894. %   \otindex..................284-304
  1895. %Range reduction
  1896. %   \redrngtofile.............401-424
  1897. %Copying
  1898. %   \filetoarray..............501-512
  1899. %   \tawfiletofile............514-523
  1900. %   \trfandwrite..............533-539
  1901. %   \steupnxtokens............525-531
  1902. %   \splitintoks..............541-542
  1903. %OTR doublecolumns
  1904. %   \bluedoublecolumnout......601-609
  1905. %   \blueonepageout...........611-620
  1906. %Auxiliaries
  1907. %   \sok......................701-705
  1908. %   \sokdef...................706-711
  1909. %History of changes
  1910. %Nov    1994 Set up.
  1911. %end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%index%
  1912. ;endverbatim
  1913. \endscript
  1914.